package com.xinxin.websocket.utils;

import com.google.gson.Gson;
import com.xinxin.websocket.dataobject.Message;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/4/29 1:58
 */
public class MessageUtils {
    private MessageUtils() {
    }

    public static String createUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    public static String createMessage(Message message) {
        return new Gson().toJson(message);
    }

    public static Object formatDate(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return format.format(date);
    }
}
